
clear all; 

%% Create par
par.a.dist='C'; 
par.a.val=100; 

par.c.dist='N'; 
par.c.val=2; 

par.b.dist='C';
par.b.val=300; 

par.z.dist='N'; 
par.z.val=4; 

par.m.dist='N'; 
par.m.val=5; 

fields=fieldnames(par); 
dim.par=length(fields); 

%% Extract positions estimated and calibrated 
pos.cal=zeros(dim.par,1); 
for ii=1:dim.par 
    fldnm=fields{ii};
    if strcmpi(par.(fldnm).dist,'C')==true
        pos.cal(ii)=1;
    end
    parIn.(fldnm)=par.(fldnm).val;     
    par2.dist.(fldnm)=par.(fldnm).dist; 
    par2.val.(fldnm)=par.(fldnm).val; 

end 
pos.est=find( pos.cal==0 ); 
pos.cal=find( pos.cal==1 ); 

dim.est=length(pos.est); 
dim.cal=length(pos.cal); 

names.est=fields(pos.est); 
names.cal=fields(pos.cal); 

newvals=randi([100,500],dim.est,1); 

%% How it is written inside the model 
tic; 
for ii=1:dim.est
    fldnm=names.est{ii};
    par2.val.(fldnm)=newvals(ii); 
end
toc; 

